# -*- coding: utf-8 -*-
"""
Created on Tue Mar 10 22:50:05 2020

@author: TSON
"""
'''
-------------------------------------------------
  File_Name：    DouglasPeuker drawing
  Author :       L_ZONGYANG
  date：         2020/03/17
-------------------------------------------------
'''
import pylab as plt
import pandas as pd
import math

import plot_map
fig = plt.figure(1,(10,8),dpi = 400)
ax = plt.subplot(111)

# bounds = [121.9,30.16,122.10,30.30]
bounds = [121.97,30.2,122.055,30.25]
plot_map.plot_map(plt,bounds,zoom = 12,style = 3)

data = pd.read_csv('E:\\Desktop\\zs\\csv\\4ships.csv')
print(data.index)#获取行的索引名称
print(data.columns)#获取列的索引名称

MMSIDATA=data['mmsi']
print(MMSIDATA)
SHIPSMMSI = list(set(MMSIDATA))
print(SHIPSMMSI)
lens=len(SHIPSMMSI)
print(lens)
for i in range(lens):
    mmsi=SHIPSMMSI[i]
    ONESHIP=data.iloc[:,:][data[data.T.index[0]]==mmsi]
    ONESHIP=ONESHIP.sort_values(by=["Unixtime"],axis=0)
    point_num=len(ONESHIP)
    start=0
    for j in range(point_num):
        if point_num<2:
            break
        if j+2>point_num:
            break
        time=(ONESHIP.iloc[j+1])['Unixtime']-(ONESHIP.iloc[j])['Unixtime']
        if time >36000:
    
            #print('oneshiptrack:time')
            start=j 
        else:
            track=ONESHIP[j:j+2]
            x_axis_data = track['longitude']
            y_axis_data = track['latitude']
            plt.plot(x_axis_data, y_axis_data, color="black", linewidth=0.5)

            #print('oneshiptrack:line')
            start=j


plt.title('AIS data',fontsize=18)
plt.xlabel('longitude')
plt.ylabel('latitude')
plt.show()
























